
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language="javascript" type="text/javascript" src="js/jquery-1.8.2.js"></script>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<script language="javascript"  type="text/javascript">
$(document).ready(function(){
		//alert('jquery ok');
	});
function checkform()
{	 var message="";
	if (document.form.username.value=="") message+="- username \n";
	if (document.form.password.value=="") message+="- password\n";
	if (document.form.telephone.value=="") message+="- telephone \n";
	if (document.form.email.value=="") message+="- email \n";
	if (message.length > 0) 
	{	alert("กรุณาใส่ข้อมูลต่อไปนี้ให้เรียบร้อย\n"+message);
		return false;
	} 	else 
	{	return true;
	}
}
function protectInjection(textbox){
		var password = textbox.value;
		//var b = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$/.test(password);
		var b = /^[a-zA-Z0-9]{6,12}$/;
	    if(pattern.test(password)){         
		//alert("true");   
		 return true;
        }else{   
		alert("Please Key information again"); 
		  return false;
        }
	}
function ValidateEmail(textbox){
		var password = textbox.value;
		 var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
         if(pattern.test(password)){         
		 alert("true");
		 return true;   
        }else{   
		alert("Email pattern not correct Ex: a@hotmai.com"); 
		  return false;
        }
	}
	
	function validatemobile(textbox) {
        var mobile = textbox.value;
        var pattern = /^\d{10}$/;
        if (pattern.test(mobile)) {
            alert("Your mobile number : "+mobile);
            return true;
        } 
            alert("It is not valid mobile number.input 10 digits number!");
            return false;

    }

</script>
<title>Register Form</title>
</head>
<body>
<div class="container" align="center" >
<form method="post" action="register" name="form" onSubmit="return checkform();" >
        <div class="page-header">
		<h1 align="center">Register Form <br></h1>
		</div>
		USERNAME : <input maxlength="10" name="username" type="text"  ><br>
		PASSWORD : <input maxlength="8" name="password" type="password" onchange="protectInjection(this);" ><br>
		TELEPHONE : <input maxlength="10" name="telephone" type="text" onchange="validatemobile(this);" ><br> 
		E-MAIL : <input name="email" type="text" onchange="ValidateEmail(this);" ><br> 
		<input type="submit" name="submit" value="submit" class="btn">
		
	</form>
</div>
</body>
</html>